package com.testjpa.dao;

import com.testjpa.entity.MyUser;
import com.testjpa.entity.MyUserInter;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.Date;
import java.util.List;

/**
 * 作者: LCG
 * 日期: 2020/5/25 10:37
 * 描述:
 */
public interface MyJpaResporstore  extends JpaRepository<MyUser,Long> {

    /**
     * 模糊查询 带分页  一个条件
     * @param userName
     * @param pageable
     * @return
     */
    public Page<MyUser> findByUserNameLike(String userName, Pageable pageable);


    /**
     * 多条件  日期 带分页
     * @return
     */
    public Page<MyUser> findByUserNameLikeAndCreateDateGreaterThan(String userName, Date createDate, Pageable pageable);


    /**
     * and in  小于等于
     * @param id
     * @param ids
     * @param pageable
     * @return
     */
    public Page<MyUser> findByIdLessThanEqualAndIdIn(Long id, List<Long> ids, Pageable pageable);


    /**
     * or  equals  使用
     * @param userName
     * @param id
     * @return
     */
    public List<MyUser> findByUserNameEqualsOrIdEquals(String userName, Long id);




    /**
     * 结果映射使用
     * @param userName
     * @return
     */
    public List<MyUserInter> findByUserNameEquals(String userName);


    public Page<MyUser> findByUserNameLikeAndCreateDateGreaterThanAndIdIn(String username, Date date, List<Long> longs, Pageable pageable);

//    public Page<MyUser> findByUserNameLikeAndIdEqualsAndOrderByIdAsc(String username, Long id, Pageable pageable);

}
